package com.example.admin.job;

import com.example.admin.client.RestClient;
import com.example.admin.client.TestClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * Created by on 2017/10/22.
 *
 * @author dj
 */
@Component
//开启定时任务
@EnableScheduling
public class HystrixJob {
	@Autowired
	private TestClient testClient;
	@Autowired
	private RestClient restClient;

	@Scheduled(cron = "0/20 * * * * ?")
	public void doJob() {
		try {
			//ribbon方式
			System.out.println(restClient.testRibbon());
			//feign方式
			//System.out.println(testClient.test());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
